<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>CKeditor</title>
	<script type="text/javascript">
// #### URLParams: holds all URL passed parameters (like ?Param1=Value1&Param2=Value2)
var FCKURLParams = new Object() ;

var aParams = document.location.search.substr(1).split('&') ;
for ( var i = 0 ; i < aParams.length ; i++ )
{
	var aParam = aParams[i].split('=') ;
	var sParamName  = aParam[0] ;
	var sParamValue = aParam[1] ;

	FCKURLParams[ sParamName ] = sParamValue ;
}

// It is preferable to have the oFCKeditor object defined in the opener window,
// so all the configurations will be there. In this way the popup doesn't need
// to take care of the configurations "clonning".
var popup = window.opener;
var oFCKeditor = window.opener[ FCKURLParams[ 'var' ] ] ;
oFCKeditor.Width	= '100%' ;
oFCKeditor.Height	= '100%' ;
oFCKeditor.Value	= popup.document.getElementById( FCKURLParams[ 'el' ] ).value ;

function Ok()
{
	var oEditor = FCKeditorAPI.GetInstance( oFCKeditor.InstanceName ) ;
	if ( oEditor.IsDirty() )
	{
		if ((window.opener.firstLoad == false) && (popup.FCKeditorAPI)) {		//already loaded
			var parentOEditor = popup.FCKeditorAPI.GetInstance(FCKURLParams[ 'el' ]);
			var parentIsWysiwyg = ( parentOEditor.EditMode == FCK_EDITMODE_WYSIWYG ) ;
			var IsWysiwyg = ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG ) ;
			if ( !IsWysiwyg && parentIsWysiwyg ) 		//copy from PLAIN (popup) to WYSIWIG (parent)
			{
				parentOEditor.SwitchEditMode();	//switch to plain
				var text = oEditor.GetData(parentOEditor.Config.FormatSource);
				parentOEditor.SetHTML( text );
			}
			else if ( parentIsWysiwyg )
			{
				var text = oEditor.EditorDocument.documentElement.innerHTML;
				parentOEditor.EditingArea.Start( text );
			}
			else
			{
				var text = oEditor.GetData(parentOEditor.Config.FormatSource);
				parentOEditor.SetHTML( text );
			}
		}
		window.opener.document.getElementById( FCKURLParams[ 'el' ] ).value = oEditor.GetData( true ) ;		// "true" means you want it formatted.
	}
	window.opener.focus() ;
	window.close() ;
	return true;
}

function Cancel()
{
	var oEditor = FCKeditorAPI.GetInstance( oFCKeditor.InstanceName ) ;
	if ( oEditor.IsDirty() )
	{
		if ( !confirm( 'Are you sure you want to cancel? Your changes will be lost.' ) )
			return ;
	}

	window.close() ;
	return true;
}

	</script>
</head>
<body style="margin:0px 0px 10px;">
	<table width="100%" cellspacing=0 cellpadding=0 height="100%">
		<tr>
			<td height="100%">
				<div id="FCKdiv" style='width:100%;height:100%'></div>
				<script type="text/javascript">
document.write( '<input type="hidden" id="' + oFCKeditor.InstanceName + '" name="' + oFCKeditor.InstanceName + '" value="' + oFCKeditor._HTMLEncode( 'nic' ) + '" style="width:100%;display:none" />' ) ;

popup.window.parent.FCK_sajax('wfSajaxWikiToHTML', [oFCKeditor.Value], function ( result ){
	var FCKinput = document.getElementById( oFCKeditor.InstanceName );
	FCKinput.value = (result.responseText);
	document.getElementById( 'FCKdiv' ).innerHTML = oFCKeditor._GetConfigHtml() + oFCKeditor._GetIFrameHtml();
});
				</script>
			</td>
		</tr>
		<tr valign="middle" height="40">
			<td align="center" >
				<input type="button" value="Ok" onclick="Ok();" style="width:120px" />
				<input type="button" value="Cancel" onclick="Cancel();" />
			</td>
		</tr>
	</table>
</body>
</html>
